package com.zhkj.txg.module.home.ui

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zhkj.txg.R
import com.zhkj.txg.module.home.entity.GrassEntity
import com.zhkj.txg.utils.ImageUtils
import com.youth.banner.adapter.BannerAdapter

class HomeGrassAdapter(
    private val context: Context
) : BannerAdapter<GrassEntity, GrassViewHolder>(null) {
    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): GrassViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_home_grass, parent, false)
        return GrassViewHolder(view)
    }

    override fun onBindView(holder: GrassViewHolder?, data: GrassEntity?, position: Int, size: Int) {
        if (holder != null && data != null) {
            holder.tvHomeRecommendContent.text = data.content
            ImageUtils.loadImage(context, holder.ivHomeRecommend, data.images)
        }
    }
}

class GrassViewHolder(view: View) : RecyclerView.ViewHolder(view) {
    val tvHomeRecommendContent: TextView = itemView.findViewById(R.id.tvHomeRecommendContent)
    val ivHomeRecommend: ImageView = itemView.findViewById(R.id.ivHomeRecommend)
}